namespace KinonekoSoftware.CodariaDB.Core
{
    public sealed class VariantsSystem : Engine
    {
        public void AddVariant(Variant variant)
        {
            Debug.Assert(variant is not null);

            VariantDB.Upsert(variant);
        }
        
        public void AddVariants(IEnumerable<Variant> variants)
        {
            
        }
        
        public void RemoveVariants(string id, string oldSpell)
        {
        }

        public IEnumerable<Variant> GetVariants(string id) => VariantDB.Find(x => x.DocumentID == id);
        public void ChangeVariants(string id, string oldSpell, string newSpell)
        {
            
        }

        protected override void OnDatabaseOpening(RepositoryOpenContext context)
        {
            VariantDB = context.Repository.Get<Variant>(CollectionNames.VariantDB);
        }
        
        protected override void OnDatabaseClosing(ILogger logger)
        {
            VariantDB = null;
        }

        public override string                   EngineID  => EngineNames.Variants;
        public          ILiteCollection<Variant> VariantDB { get; private set; }
    }
}